More label and image sizing fixes
authorMatthias Clasen <mclasen@redhat.com>
Tue, 27 May 2014 10:00:21 +0000 (06:00 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 27 May 2014 10:00:21 +0000 (06:00 -0400)
Go back to respecting GtkMisc::xpad/ypad. Not doing so breaks
the misc-alignment reftest. As long as we still derive from
GtkMisc, we may as well do this.

gtk/gtkimage.c
gtk/gtklabel.c

index 115920b1f3dae571fb26ac13cdcdcf159dd05a04..17482c3e11fe4dceb0ae65fcf97f902903e0557d 100644 (file)
@@ -33,6 +33,7 @@
 #include "gtkimageprivate.h"
 #include "deprecated/gtkiconfactory.h"
 #include "deprecated/gtkstock.h"
+#include "deprecated/gtkmisc.h"
 #include "gtkicontheme.h"
 #include "gtksizerequest.h"
 #include "gtkintl.h"
@@ -1520,11 +1521,21 @@ gtk_image_get_padding_and_border (GtkImage  *image,
   GtkStyleContext *context;
   GtkStateFlags state;
   GtkBorder tmp;
+  gint xpad, ypad;
 
   context = gtk_widget_get_style_context (GTK_WIDGET (image));
   state = gtk_widget_get_state_flags (GTK_WIDGET (image));
 
   gtk_style_context_get_padding (context, state, border);
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+  gtk_misc_get_padding (GTK_MISC (image), &xpad, &ypad);
+  border->top += ypad;
+  border->left += xpad;
+  border->bottom += ypad;
+  border->right += xpad;
+G_GNUC_END_IGNORE_DEPRECATIONS
+
   gtk_style_context_get_border (context, state, &tmp);
   border->top += tmp.top;
   border->right += tmp.right;
@@ -1640,7 +1651,6 @@ gtk_image_draw (GtkWidget *widget,
   GtkStyleContext *context;
   gint x, y, width, height, baseline;
   gfloat xalign, yalign;
-  GtkStateFlags state;
   GtkBorder border;
    
   g_return_val_if_fail (GTK_IS_IMAGE (widget), FALSE);
@@ -1649,8 +1659,6 @@ gtk_image_draw (GtkWidget *widget,
   priv = image->priv;
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (GTK_WIDGET (image));
-  gtk_style_context_get_border (context, state, &border);
 
   gtk_render_background (context, cr,
                          0, 0,
@@ -1661,7 +1669,7 @@ gtk_image_draw (GtkWidget *widget,
 
   xalign = halign_to_float (widget);
   yalign = valign_to_float (widget);
-
+  gtk_image_get_padding_and_border (image, &border);
   gtk_image_get_preferred_size (image, &width, &height);
 
   baseline = gtk_widget_get_allocated_baseline (widget);
index 9bcf856deea3934bbdeb5db2af6c9d59dc4f1356..bedfc1ed82d8789fae17b86f7d579c3fa4769428 100644 (file)
@@ -50,6 +50,7 @@
 #include "gtkprivate.h"
 #include "gtktypebuiltins.h"
 #include "gtkmain.h"
+#include "deprecated/gtkmisc.h"
 
 #include "a11y/gtklabelaccessibleprivate.h"
 
@@ -3226,11 +3227,21 @@ gtk_label_get_padding_and_border (GtkLabel  *label,
   GtkStyleContext *context;
   GtkStateFlags state;
   GtkBorder tmp;
+  gint xpad, ypad;
 
   context = gtk_widget_get_style_context (GTK_WIDGET (label));
   state = gtk_widget_get_state_flags (GTK_WIDGET (label));
 
   gtk_style_context_get_padding (context, state, border);
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+  gtk_misc_get_padding (GTK_MISC (label), &xpad, &ypad);
+  border->top += ypad;
+  border->left += xpad;
+  border->bottom += ypad;
+  border->right += xpad;
+G_GNUC_END_IGNORE_DEPRECATIONS
+
   gtk_style_context_get_border (context, state, &tmp);
   border->top += tmp.top;
   border->right += tmp.right;